//
//  TabBarController.m
//  AngelaBaby
//
//  Created by lanou3g on 15/10/13.
//  Copyright © 2015年 lanou3g. All rights reserved.
//

#import "TabBarController.h"
#import "HomeViewController.h"
#import "CategoryViewController.h"
#import "SearchViewController.h"


@interface TabBarController ()

@property(nonatomic,strong)HomeViewController *homeVC;

@end

@implementation TabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
       [self setSubControllers];
}


-(void)setSubControllers{
    _homeVC=[[HomeViewController alloc]init];
    _homeVC.edgesForExtendedLayout=UIRectEdgeNone;
    UINavigationController *hVC=[[UINavigationController alloc]initWithRootViewController:_homeVC];
     hVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"首页" image:[UIImage imageNamed:@""] tag:1001];
    [_homeVC.navigationItem setTitle:@"首页"];
    _homeVC.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"search_icon@2x.png"] style:UIBarButtonItemStylePlain target:self action:@selector(presentTo:)];
    CategoryViewController *categoryVC=[[CategoryViewController alloc]init];
    
    UINavigationController *cVC=[[UINavigationController alloc]initWithRootViewController:categoryVC];
    cVC.edgesForExtendedLayout=UIRectEdgeNone;
    cVC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"分类" image:[UIImage imageNamed:@""] tag:1002];
    categoryVC.navigationItem.title = @"分类";
    NSArray *nVCArray =@[hVC,cVC];
    self.viewControllers = nVCArray;
}



-(void)presentTo:(UIBarButtonItem *)sender{
    SearchViewController *searchVC=[[SearchViewController alloc]init];
    searchVC.edgesForExtendedLayout=UIRectEdgeNone;
    UINavigationController *searchNVC=[[UINavigationController alloc]initWithRootViewController:searchVC];

    [self.homeVC presentViewController:searchNVC animated:YES completion:nil];
}





- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
